home *** CD-ROM | disk | FTP | other *** search
- // ===============================================================
- // Vertex Program:
- // Description:
- // Last Update: 14/08/2003
- // Coder: Andrey Honich
- // ===============================================================
-
- #include "../CGVPMacro.csi"
-
-
- VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
- MainInput { VIEWPROJ_MATRIX, LIGHT_POS, TEX_MATRIX2x4, ATTEN }
- DeclarationsScript
- {
- IN_T0_C0_TANG
- OUT_T0_T1_T2_T3_C0_C1
- }
- PositionScript = PosCommon
- CoreScript
- {
- float2 tCoords = mul(TexMatrix, IN.TexCoord0);
- OUT.Tex0.xy = tCoords;
- OUT.Tex1.xy = tCoords;
-
- // store normalized light vector
- float3 lVec = LightPos.xyz - vPos.xyz;
- float3 nlVec = normalize(lVec);
-
- float3 normal = IN.TNormal;
- float fDot = dot(nlVec, normal);
- normal = normal * sign(fDot);
-
- // compute the 3x3 tranform from tangent space to object space
- float3x3 objToTangentSpace;
- objToTangentSpace[0] = IN.Tangent;
- objToTangentSpace[1] = IN.Binormal;
- objToTangentSpace[2] = normal;
-
- float3 lightVec = mul(objToTangentSpace, lVec);
-
- float3 vDist = PROC_ATTENPIX;
- // transform light vector from object space to tangent space and pass it as a tex coords
- OUT.Tex3.xyz = vDist;
- OUT.Color1.xyz = vDist;
-
- OUT.Tex2.xyz = mul(objToTangentSpace, LightPos.xyz - vPos.xyz);
- OUT.Color = IN.Color;
- }
-